<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <div id="app">
        <h2>{{counter}}</h2>
        <!-- <button v-on:click="counter++">+</button> -->
        <!-- <button v-on:click="counter--">-</button> -->

        <!-- <button v-on:click="incr">+</button> -->
        <!-- <button v-on:click="decr">-</button> -->

        <!-- 语法糖写法 -->
        <button @click="incr">+</button>
        <button @click="decr">-</button>
    </div>

    <script src="../js/vue.js"></script>
    <script>
        const app = new Vue({
            el: '#app',
            data: {
                counter: 0
            },
            methods: {
                incr(){
                    this.counter++
                },
                decr(){
                    this.counter--
                }
            }
        })
    </script>
</body>
</html>